import request from "@/utils/request";
const BASE = "/financial/deposit";
// 生成二维码
export function getcirclemaster(data) {
  // 当有项目步骤的时候
  if (data.flowId) {
    return request({
      url: `${BASE}/getPayQrCode?id=${data.id}&type=${data.type}&circleId=${
        data.circleId ? data.circleId : ""
      }&email=${data.email}&flowId=${data.flowId}&nextFlowId=${
        data.nextFlowId
      }`,
      method: "POST",
    });
  } else {
    return request({
      url: `${BASE}/getPayQrCode?id=${data.id}&type=${data.type}&circleId=${
        data.circleId ? data.circleId : ""
      }&email=${data.email}`,
      method: "POST",
    });
  }
}

// 获取自定义问金充值二维码 /financial/deposit/getPayQrCodeByAmount
export function getPayQrCodeByAmountApi(data) {
  return request({
    url: `/financial/deposit/getPayQrCodeByAmount?type=${data.type}&circleId=${
      data.circleId ? data.circleId : ""
    }&amount=${data.amount}&email=${data.email}`,
    method: "POST",
  });
}

// 获取余额
export function getcircleuserBalanceApi(phone) {
  return request({
    url: `${BASE}/userBalance?phone=${phone}`,
    method: "GET",
  });
}

//获取可以转让的余额
export function getuserBalanceApi() {
  return request({
    url: `${BASE}/userTransferBalance`,
    method: "GET",
  });
}

// 问金转让
export function getcircleusertransferApi(data) {
  return request({
    url: `${BASE}/transfer?amount=${data.amount}&phone=${data.phone}`,
    method: "POST",
  });
}

// 分页查询
export function getcircleuserListApi(params) {
  return request({
    url: `${BASE}/list`,
    method: "GET",
    params,
  });
}
// 创建问金充值订单
export function createDepositOrderApi(data) {
  let url
  if(data.id){
      url = `${BASE}/createDepositOrder?amount=${data.amount}&circleId=${data.circleId}&id=${data.id}`
  }else{
    url = `${BASE}/createDepositOrder?amount=${data.amount}&circleId=${data.circleId}`
  }
  return request({
    url,
    method: "post",
  });
}
// 微信支付
export function depositWxPayApi(data) {
  return request({
    url: `${BASE}/wxPay?id=${data.id}&type=${data.type}`,
    method: "get"
  });
}

// 问金支付
export function getDepositVoucherPayApi(data) {
  // 当有项目步骤的时候
  if (data.flowId) {
    return request({
      url: `${BASE}/voucherPay?circleId=${data.circleId}&orderId=${
        data.orderId
      }&flowId=${data.flowId}&nextFlowId=${
        data.nextFlowId ? data.nextFlowId : ""
      }&email=${data.email ? data.email : ""}`,
      method: "POST",
    });
  } else {
    return request({
      url: `${BASE}/voucherPay?circleId=${data.circleId}&orderId=${
        data.orderId
      }&email=${data.email ? data.email : ""}`,
      method: "POST",
    });
  }
}

// 查询手机号 /service/circle/list
export function getCircleListApi(phone, isFilter) {
  if (isFilter) {
    return request({
      url: `/service/circle/list?phone=${phone}&isFilter=${isFilter}`,
      method: "GET",
    });
  } else {
    return request({
      url: `/service/circle/list?phone=${phone}`,
      method: "GET",
    });
  }
}

// 获取自定义金额充值后获得多少问金 /financial/deposit/getQrAmount
export function getDepositQrAmountApi(amount) {
  return request({
    url: `${BASE}/getQrAmount?amount=${amount}`,
    method: "get",
  });
}

// 修改当前问圈的logo /service/circle/updateCircleLogo
export function updateCircleLogoApi(data) {
  return request({
    url: `/service/circle/updateCircleLogo`,
    method: "put",
    data
  });
}

// 获取所有问圈 /service/circle/selectCircleByUserId
export function getSelectCircleByUserIdApi(params) {
  return request({
    url: `/service/circle/selectCircleByUserId`,
    method: "get",
    params
  });
}

// 切换问圈 /service/circle/updateDefault
export function cutCircleUpdateDefaultApi(circleId) {
  return request({
    url: `/service/circle/updateDefault?circleId=${circleId}`,
    method: "put",
  });
}

// 获取当前问圈的余额 /financial/deposit/circleBalance
export function getCircleBalanceApi(params) {
  return request({
    url: `/financial/deposit/circleBalance`,
    method: "get",
    params
  });
}

// 任命用户角色(人事和查阅者) /service/circle/updateCircleRole
export function updateCircleRoleApi(data) {
  return request({
    url: `/service/circle/updateCircleRole?circleId=${data.circleId}&userId=${data.userId}&role=${data.role}`,
    method: "put",
  });
}

// 查询在这个问圈的角色 /service/circle/getCircleRole
export function getCircleRoleApi(params) {
  return request({
    url: `/service/circle/getCircleRole`,
    method: "get",
    params
  });
}


// 创建会话
export function imCreateSessionApi(data) {
    return request({
        url: `/service/im/createSession`,
        method: "post",
        data
    })
}

// 创建单聊会话
export function imSelectSessionApi(params) {
  return request({
    url: `/service/im/selectSession`,
    method: "get",
    params
  });
}